package com.example.util;

import org.jetbrains.annotations.NotNull;

public class StringUtil {

    /**
     * 判断是否是空
     */
    public static boolean isEmpty(String str) {
        return str == null || "".equals(str.trim());
    }

    /**
     * 判断是否不是空
     */
    public static boolean isNotEmpty(String str) {
        return (str != null) && !"".equals(str.trim());
    }

    /**
     * 格式化模糊查询
     */
    public static String formatLike(String str) {
        if (isNotEmpty(str)) {
            return "%" + str + "%";
        } else {
            return null;
        }
    }

    public static boolean isNumber(char c){
        return c >= 48 && c <= 57;
    }

    public static String getNumber(@NotNull String str){
        StringBuilder str1 = new StringBuilder();
        for(String c : str.split("")){
            if(isNumber(c.charAt(0)))
                str1.append(c.charAt(0));
        }
        return str1.toString();
    }

}

